<?php
//Initial date: 2009-05-30
//Last change: 2009-05-30 by Kamil Jaskiewicz

class departments extends DBTable
{
	public $DB;

	public function __construct($ID=false)
	{
		parent::__construct("departments");
		if ($ID) {
			$this->findID($ID);
		}
	}

	public function findID($id) {
		$this->DB->query("SELECT * FROM vw_departments WHERE dept_id='$id'");
		return $this->getNext();
	}

	public function selectAll()
	{
		$this->DB->query("SELECT * FROM vw_departments");
		return $this->DB->RowCount;
	}

	public function selectForCompany($id)
	{
		$this->DB->query("SELECT * FROM vw_departments WHERE dept_company_id='$id'");
		return $this->DB->RowCount;
	}

	public function delete($id)
	{
		$this->DB->query("DELETE FROM departments WHERE dept_id='$id'");
		return $this->DB->RowCount;
	}

}

?>
